package com.example.service1.common.api.entity;

/**
 * 常用API响应码
 */
public enum ServiceStateCode implements StateCode{
//==========================|| 服务器响应码 ||===================================
    DISABLE_MALICIOUS_REQUEST(100,"禁止恶意请求"),
    SUCCESS(200,"业务正确执行"),
    PARAMETER_NONSTANDARD(405,"参数不规范"),
    IRREGULAR_ACCESS(406,"访问不规范"),
    FAILURE(500,"服务器出错了"),
    CURRENT_LIMITING(501,"服务限流"),
    ;
    private long code;
    private String message;

    private ServiceStateCode(long code, String message) {
        this.code = code;
        this.message = message;
    }

    public long getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * 如果业务正常执行，则会返回SUCCESS
     * 所以correctExecBusiness是判断是否返回SUCCESS
     * 如果是，则返回true，否则返回false
     * @return
     */
    public boolean correctExecBusiness(){
        if(ServiceStateCode.SUCCESS.equals(this)){
            return true;
        }
        return false;
    }
}
